{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# The Canonical Time-series Characteristics (catch22) transform\n",
    "\n",
    "catch22\\[1\\] is a collection of 22 time series features extracted from the 7000+ present in the _hctsa_ \\[2\\]\\[3\\] toolbox.\n",
    "A hierarchical clustering was performed on the correlation matrix of features that performed better than random chance to remove redundancy.\n",
    "These clusters were sorted by balanced accuracy using a decision tree classifier and a single feature was selected from the 22 clusters formed, taking into account balanced accuracy results, computational efficiency and interpretability.\n",
    "\n",
    "In this notebook, we will demonstrate how to use the catch22 transformer on the ItalyPowerDemand univariate and BasicMotions multivariate datasets. We also show catch22 used for classification with a random forest classifier.\n",
    "\n",
    "#### References:\n",
    "\n",
    "\\[1\\] Lubba, C. H., Sethi, S. S., Knaute, P., Schultz, S. R., Fulcher, B. D., & Jones, N. S. (2019). catch22: CAnonical Time-series CHaracteristics. Data Mining and Knowledge Discovery, 33(6), 1821-1852.\n",
    "\n",
    "\\[2\\] Fulcher, B. D., & Jones, N. S. (2017). hctsa: A computational framework for automated time-series phenotyping using massive feature extraction. Cell systems, 5(5), 527-531.\n",
    "\n",
    "\\[3\\] Fulcher, B. D., Little, M. A., & Jones, N. S. (2013). Highly comparative time-series analysis: the empirical structure of time series and their methods. Journal of the Royal Society Interface, 10(83), 20130048."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:07.306937Z",
     "iopub.status.busy": "2020-12-19T14:30:07.306390Z",
     "iopub.status.idle": "2020-12-19T14:30:08.036353Z",
     "shell.execute_reply": "2020-12-19T14:30:08.036857Z"
    }
   },
   "outputs": [],
   "source": [
    "from sklearn import metrics\n",
    "\n",
    "from sktime.classification.feature_based import Catch22Classifier\n",
    "from sktime.datasets import load_basic_motions, load_italy_power_demand\n",
    "from sktime.transformations.panel.catch22 import Catch22"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Load data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.041533Z",
     "iopub.status.busy": "2020-12-19T14:30:08.041060Z",
     "iopub.status.idle": "2020-12-19T14:30:08.210768Z",
     "shell.execute_reply": "2020-12-19T14:30:08.211258Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(67, 1) (67,) (50, 1) (50,)\n",
      "(40, 6) (40,) (40, 6) (40,)\n"
     ]
    }
   ],
   "source": [
    "IPD_X_train, IPD_y_train = load_italy_power_demand(split=\"train\", return_X_y=True)\n",
    "IPD_X_test, IPD_y_test = load_italy_power_demand(split=\"test\", return_X_y=True)\n",
    "IPD_X_test = IPD_X_test[:50]\n",
    "IPD_y_test = IPD_y_test[:50]\n",
    "\n",
    "print(IPD_X_train.shape, IPD_y_train.shape, IPD_X_test.shape, IPD_y_test.shape)\n",
    "\n",
    "BM_X_train, BM_y_train = load_basic_motions(split=\"train\", return_X_y=True)\n",
    "BM_X_test, BM_y_test = load_basic_motions(split=\"test\", return_X_y=True)\n",
    "\n",
    "print(BM_X_train.shape, BM_y_train.shape, BM_X_test.shape, BM_y_test.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. catch22 transform\n",
    "\n",
    "### Univariate\n",
    "\n",
    "The catch22 features are provided in the form of a transformer, `Catch22`.\n",
    "From this the transformed data can be used for a variety of time series analysis tasks."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.215545Z",
     "iopub.status.busy": "2020-12-19T14:30:08.215049Z",
     "iopub.status.idle": "2020-12-19T14:30:08.222937Z",
     "shell.execute_reply": "2020-12-19T14:30:08.223422Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c {color: black;background-color: white;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c pre{padding: 0;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-toggleable {background-color: white;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-estimator:hover {background-color: #d4ebff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-item {z-index: 1;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel-item {display: flex;flex-direction: column;position: relative;background-color: white;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-parallel-item:only-child::after {width: 0;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;position: relative;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-label label {font-family: monospace;font-weight: bold;background-color: white;display: inline-block;line-height: 1.2em;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-label-container {position: relative;z-index: 2;text-align: center;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c div.sk-text-repr-fallback {display: none;}</style><div id='sk-8f29edb6-8bf5-4530-aced-70f7f86ef71c' class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Catch22()</pre><b>Please rerun this cell to show the HTML repr or trust the notebook.</b></div><div class=\"sk-container\" hidden><div class='sk-item'><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=UUID('ec470465-643b-4953-9266-7c8b4cd6340d') type=\"checkbox\" checked><label for=UUID('ec470465-643b-4953-9266-7c8b4cd6340d') class='sk-toggleable__label sk-toggleable__label-arrow'>Catch22</label><div class=\"sk-toggleable__content\"><pre>Catch22()</pre></div></div></div></div></div>"
      ],
      "text/plain": [
       "Catch22()"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c22_uv = Catch22()\n",
    "c22_uv.fit(IPD_X_train, IPD_y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.226714Z",
     "iopub.status.busy": "2020-12-19T14:30:08.226142Z",
     "iopub.status.idle": "2020-12-19T14:30:08.252491Z",
     "shell.execute_reply": "2020-12-19T14:30:08.252970Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/homebrew/Caskroom/miniforge/base/envs/sktime/lib/python3.9/site-packages/numba/cpython/hashing.py:482: UserWarning: FNV hashing is not implemented in Numba. See PEP 456 https://www.python.org/dev/peps/pep-0456/ for rationale over not using FNV. Numba will continue to work, but hashes for built in types will be computed using siphash24. This will permit e.g. dictionaries to continue to behave as expected, however anything relying on the value of the hash opposed to hash as a derived property is likely to not work as expected.\n",
      "  warnings.warn(msg)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>12</th>\n",
       "      <th>13</th>\n",
       "      <th>14</th>\n",
       "      <th>15</th>\n",
       "      <th>16</th>\n",
       "      <th>17</th>\n",
       "      <th>18</th>\n",
       "      <th>19</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.158630</td>\n",
       "      <td>-0.217227</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.291667</td>\n",
       "      <td>-0.625000</td>\n",
       "      <td>3.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.468052</td>\n",
       "      <td>0.589049</td>\n",
       "      <td>0.836755</td>\n",
       "      <td>...</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.778748</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.240598</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.040000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.918162</td>\n",
       "      <td>-0.214762</td>\n",
       "      <td>15.0</td>\n",
       "      <td>0.208333</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>4.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.702775</td>\n",
       "      <td>0.196350</td>\n",
       "      <td>0.666160</td>\n",
       "      <td>...</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.869565</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.730238</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.388217</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.273180</td>\n",
       "      <td>-0.085856</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.875000</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.310567</td>\n",
       "      <td>0.589049</td>\n",
       "      <td>0.865073</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.913043</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.836012</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.089104</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.034014</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.048411</td>\n",
       "      <td>-0.450080</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>-0.625000</td>\n",
       "      <td>4.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.804047</td>\n",
       "      <td>0.196350</td>\n",
       "      <td>0.648309</td>\n",
       "      <td>...</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.869565</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.605420</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.332436</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.426379</td>\n",
       "      <td>0.572566</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.291667</td>\n",
       "      <td>-0.666667</td>\n",
       "      <td>4.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.675485</td>\n",
       "      <td>0.196350</td>\n",
       "      <td>0.657946</td>\n",
       "      <td>...</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.913043</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.730238</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.318405</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         0         1     2         3         4    5     6         7   \\\n",
       "0  1.158630 -0.217227   8.0  0.291667 -0.625000  3.0   6.0  0.468052   \n",
       "1  0.918162 -0.214762  15.0  0.208333 -0.666667  4.0   8.0  0.702775   \n",
       "2 -0.273180 -0.085856   4.0  0.875000  0.250000  2.0   5.0  0.310567   \n",
       "3  0.048411 -0.450080  13.0  0.166667 -0.625000  4.0  10.0  0.804047   \n",
       "4  0.426379  0.572566  16.0  0.291667 -0.666667  4.0   7.0  0.675485   \n",
       "\n",
       "         8         9   ...   12        13   14        15        16        17  \\\n",
       "0  0.589049  0.836755  ...  3.0  1.000000  5.0  1.778748  0.750000  0.240598   \n",
       "1  0.196350  0.666160  ...  4.0  0.869565  5.0  1.730238  0.500000  0.388217   \n",
       "2  0.589049  0.865073  ...  2.0  0.913043  5.0  1.836012  0.666667  0.089104   \n",
       "3  0.196350  0.648309  ...  4.0  0.869565  6.0  1.605420  0.666667  0.332436   \n",
       "4  0.196350  0.657946  ...  4.0  0.913043  6.0  1.730238  0.500000  0.318405   \n",
       "\n",
       "   18  19        20  21  \n",
       "0 NaN NaN  0.040000 NaN  \n",
       "1 NaN NaN  0.111111 NaN  \n",
       "2 NaN NaN  0.034014 NaN  \n",
       "3 NaN NaN  0.111111 NaN  \n",
       "4 NaN NaN  0.111111 NaN  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "transformed_data_uv = c22_uv.transform(IPD_X_train)\n",
    "transformed_data_uv.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Please note, that Catch22 doesn't take labels (`y`) into consideration in the `fit(x, y=None)` method, so we can easily replace it with a single-step `fit_transform` method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c22_uv_single_step = Catch22()\n",
    "transformed_data_uv_single_step = c22_uv.fit_transform(IPD_X_train)\n",
    "transformed_data_uv_single_step.equals(transformed_data_uv)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multivariate\n",
    "\n",
    "Transformation of multivariate data is supported by `Catch22`.\n",
    "The default procedure will concatenate each column prior to transformation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.264541Z",
     "iopub.status.busy": "2020-12-19T14:30:08.264050Z",
     "iopub.status.idle": "2020-12-19T14:30:08.266022Z",
     "shell.execute_reply": "2020-12-19T14:30:08.266517Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>dim_0__0</th>\n",
       "      <th>dim_0__1</th>\n",
       "      <th>dim_0__2</th>\n",
       "      <th>dim_0__3</th>\n",
       "      <th>dim_0__4</th>\n",
       "      <th>dim_0__5</th>\n",
       "      <th>dim_0__6</th>\n",
       "      <th>dim_0__7</th>\n",
       "      <th>dim_0__8</th>\n",
       "      <th>dim_0__9</th>\n",
       "      <th>...</th>\n",
       "      <th>dim_5__12</th>\n",
       "      <th>dim_5__13</th>\n",
       "      <th>dim_5__14</th>\n",
       "      <th>dim_5__15</th>\n",
       "      <th>dim_5__16</th>\n",
       "      <th>dim_5__17</th>\n",
       "      <th>dim_5__18</th>\n",
       "      <th>dim_5__19</th>\n",
       "      <th>dim_5__20</th>\n",
       "      <th>dim_5__21</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.140988</td>\n",
       "      <td>-0.268073</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.890</td>\n",
       "      <td>0.160</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.042638</td>\n",
       "      <td>0.736311</td>\n",
       "      <td>0.314500</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.707071</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.907929</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.658286</td>\n",
       "      <td>0.828571</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>0.012550</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.387256</td>\n",
       "      <td>-0.126246</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.920</td>\n",
       "      <td>-0.600</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.269591</td>\n",
       "      <td>0.490874</td>\n",
       "      <td>0.614552</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.727273</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.875354</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.206944</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.257143</td>\n",
       "      <td>0.028935</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.028412</td>\n",
       "      <td>-0.224988</td>\n",
       "      <td>9.0</td>\n",
       "      <td>-0.335</td>\n",
       "      <td>-0.045</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.036650</td>\n",
       "      <td>1.030835</td>\n",
       "      <td>0.352408</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.818182</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.789838</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.791912</td>\n",
       "      <td>0.828571</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>0.054977</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.147338</td>\n",
       "      <td>-0.199523</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-0.540</td>\n",
       "      <td>0.180</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.013833</td>\n",
       "      <td>1.030835</td>\n",
       "      <td>0.212988</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.717172</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.904917</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1.191592</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.171429</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.217645</td>\n",
       "      <td>-0.252015</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-0.130</td>\n",
       "      <td>0.020</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.008072</td>\n",
       "      <td>0.883573</td>\n",
       "      <td>0.150597</td>\n",
       "      <td>...</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.707071</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.880930</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.141568</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.002449</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 132 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   dim_0__0  dim_0__1  dim_0__2  dim_0__3  dim_0__4  dim_0__5  dim_0__6  \\\n",
       "0 -0.140988 -0.268073       6.0    -0.890     0.160       2.0       3.0   \n",
       "1 -0.387256 -0.126246       6.0    -0.920    -0.600       2.0       4.0   \n",
       "2  0.028412 -0.224988       9.0    -0.335    -0.045       1.0       3.0   \n",
       "3 -0.147338 -0.199523       8.0    -0.540     0.180       1.0       5.0   \n",
       "4 -0.217645 -0.252015       7.0    -0.130     0.020       1.0       6.0   \n",
       "\n",
       "   dim_0__7  dim_0__8  dim_0__9  ...  dim_5__12  dim_5__13  dim_5__14  \\\n",
       "0  0.042638  0.736311  0.314500  ...        2.0   0.707071        7.0   \n",
       "1  0.269591  0.490874  0.614552  ...        2.0   0.727273        6.0   \n",
       "2  0.036650  1.030835  0.352408  ...        2.0   0.818182        7.0   \n",
       "3  0.013833  1.030835  0.212988  ...        2.0   0.717172        6.0   \n",
       "4  0.008072  0.883573  0.150597  ...        2.0   0.707071        7.0   \n",
       "\n",
       "   dim_5__15  dim_5__16  dim_5__17  dim_5__18  dim_5__19  dim_5__20  dim_5__21  \n",
       "0   1.907929       1.00   0.658286   0.828571   0.228571   0.012550        9.0  \n",
       "1   1.875354       0.50   0.206944   0.600000   0.257143   0.028935        9.0  \n",
       "2   1.789838       0.75   0.791912   0.828571   0.228571   0.054977       11.0  \n",
       "3   1.904917       1.00   1.191592   0.600000   0.171429   0.015611        9.0  \n",
       "4   1.880930       1.00   3.141568   0.800000   0.200000   0.002449       10.0  \n",
       "\n",
       "[5 rows x 132 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c22_mv = Catch22()\n",
    "transformed_data_mv = c22_mv.fit_transform(BM_X_train)\n",
    "transformed_data_mv.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also set specific column names, e.g., `\"short_str_feat\"` which will show short name of the feature in the column name.\n",
    "\n",
    "If the location and spread of the raw time-series distribution may be important, set `catch24 = true` to include additionally `Mean` and `StandardDeviation` values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-f40df984-b2db-4941-afd9-ed30d47165e4 {color: black;background-color: white;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 pre{padding: 0;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-toggleable {background-color: white;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-estimator:hover {background-color: #d4ebff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-item {z-index: 1;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel-item {display: flex;flex-direction: column;position: relative;background-color: white;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-parallel-item:only-child::after {width: 0;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;position: relative;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-label label {font-family: monospace;font-weight: bold;background-color: white;display: inline-block;line-height: 1.2em;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-label-container {position: relative;z-index: 2;text-align: center;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-f40df984-b2db-4941-afd9-ed30d47165e4 div.sk-text-repr-fallback {display: none;}</style><div id='sk-f40df984-b2db-4941-afd9-ed30d47165e4' class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Catch22(catch24=True, col_names=&#x27;short_str_feat&#x27;)</pre><b>Please rerun this cell to show the HTML repr or trust the notebook.</b></div><div class=\"sk-container\" hidden><div class='sk-item'><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=UUID('844097ed-d4cd-4df6-91cc-5d9a9b79d7f7') type=\"checkbox\" checked><label for=UUID('844097ed-d4cd-4df6-91cc-5d9a9b79d7f7') class='sk-toggleable__label sk-toggleable__label-arrow'>Catch22</label><div class=\"sk-toggleable__content\"><pre>Catch22(catch24=True, col_names=&#x27;short_str_feat&#x27;)</pre></div></div></div></div></div>"
      ],
      "text/plain": [
       "Catch22(catch24=True, col_names='short_str_feat')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c24_mv = Catch22(col_names=\"short_str_feat\", catch24=True)\n",
    "c24_mv.fit(BM_X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>dim_0__mode_5</th>\n",
       "      <th>dim_0__mode_10</th>\n",
       "      <th>dim_0__stretch_decreasing</th>\n",
       "      <th>dim_0__outlier_timing_pos</th>\n",
       "      <th>dim_0__outlier_timing_neg</th>\n",
       "      <th>dim_0__acf_timescale</th>\n",
       "      <th>dim_0__acf_first_min</th>\n",
       "      <th>dim_0__centroid_freq</th>\n",
       "      <th>dim_0__low_freq_power</th>\n",
       "      <th>dim_0__forecast_error</th>\n",
       "      <th>...</th>\n",
       "      <th>dim_5__stretch_high</th>\n",
       "      <th>dim_5__rs_range</th>\n",
       "      <th>dim_5__whiten_timescale</th>\n",
       "      <th>dim_5__embedding_dist</th>\n",
       "      <th>dim_5__dfa</th>\n",
       "      <th>dim_5__rs_range</th>\n",
       "      <th>dim_5__transition_matrix</th>\n",
       "      <th>dim_5__periodicity</th>\n",
       "      <th>dim_5__mean</th>\n",
       "      <th>dim_5__std</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.140988</td>\n",
       "      <td>-0.268073</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.890</td>\n",
       "      <td>0.160</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.042638</td>\n",
       "      <td>0.736311</td>\n",
       "      <td>0.314500</td>\n",
       "      <td>...</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.907929</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.658286</td>\n",
       "      <td>0.828571</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>0.012550</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.054413</td>\n",
       "      <td>0.510274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.387256</td>\n",
       "      <td>-0.126246</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-0.920</td>\n",
       "      <td>-0.600</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.269591</td>\n",
       "      <td>0.490874</td>\n",
       "      <td>0.614552</td>\n",
       "      <td>...</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.875354</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.206944</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.257143</td>\n",
       "      <td>0.028935</td>\n",
       "      <td>9.0</td>\n",
       "      <td>-0.102407</td>\n",
       "      <td>0.661172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.028412</td>\n",
       "      <td>-0.224988</td>\n",
       "      <td>9.0</td>\n",
       "      <td>-0.335</td>\n",
       "      <td>-0.045</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.036650</td>\n",
       "      <td>1.030835</td>\n",
       "      <td>0.352408</td>\n",
       "      <td>...</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.789838</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.791912</td>\n",
       "      <td>0.828571</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>0.054977</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.031881</td>\n",
       "      <td>0.499788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.147338</td>\n",
       "      <td>-0.199523</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-0.540</td>\n",
       "      <td>0.180</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.013833</td>\n",
       "      <td>1.030835</td>\n",
       "      <td>0.212988</td>\n",
       "      <td>...</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.904917</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1.191592</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.171429</td>\n",
       "      <td>0.015611</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.029537</td>\n",
       "      <td>0.248161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.217645</td>\n",
       "      <td>-0.252015</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-0.130</td>\n",
       "      <td>0.020</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.008072</td>\n",
       "      <td>0.883573</td>\n",
       "      <td>0.150597</td>\n",
       "      <td>...</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.880930</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.141568</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.002449</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.013344</td>\n",
       "      <td>0.163754</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 144 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   dim_0__mode_5  dim_0__mode_10  dim_0__stretch_decreasing  \\\n",
       "0      -0.140988       -0.268073                        6.0   \n",
       "1      -0.387256       -0.126246                        6.0   \n",
       "2       0.028412       -0.224988                        9.0   \n",
       "3      -0.147338       -0.199523                        8.0   \n",
       "4      -0.217645       -0.252015                        7.0   \n",
       "\n",
       "   dim_0__outlier_timing_pos  dim_0__outlier_timing_neg  dim_0__acf_timescale  \\\n",
       "0                     -0.890                      0.160                   2.0   \n",
       "1                     -0.920                     -0.600                   2.0   \n",
       "2                     -0.335                     -0.045                   1.0   \n",
       "3                     -0.540                      0.180                   1.0   \n",
       "4                     -0.130                      0.020                   1.0   \n",
       "\n",
       "   dim_0__acf_first_min  dim_0__centroid_freq  dim_0__low_freq_power  \\\n",
       "0                   3.0              0.042638               0.736311   \n",
       "1                   4.0              0.269591               0.490874   \n",
       "2                   3.0              0.036650               1.030835   \n",
       "3                   5.0              0.013833               1.030835   \n",
       "4                   6.0              0.008072               0.883573   \n",
       "\n",
       "   dim_0__forecast_error  ...  dim_5__stretch_high  dim_5__rs_range  \\\n",
       "0               0.314500  ...                  7.0         1.907929   \n",
       "1               0.614552  ...                  6.0         1.875354   \n",
       "2               0.352408  ...                  7.0         1.789838   \n",
       "3               0.212988  ...                  6.0         1.904917   \n",
       "4               0.150597  ...                  7.0         1.880930   \n",
       "\n",
       "   dim_5__whiten_timescale  dim_5__embedding_dist  dim_5__dfa  \\\n",
       "0                     1.00               0.658286    0.828571   \n",
       "1                     0.50               0.206944    0.600000   \n",
       "2                     0.75               0.791912    0.828571   \n",
       "3                     1.00               1.191592    0.600000   \n",
       "4                     1.00               3.141568    0.800000   \n",
       "\n",
       "   dim_5__rs_range  dim_5__transition_matrix  dim_5__periodicity  dim_5__mean  \\\n",
       "0         0.228571                  0.012550                 9.0     0.054413   \n",
       "1         0.257143                  0.028935                 9.0    -0.102407   \n",
       "2         0.228571                  0.054977                11.0     0.031881   \n",
       "3         0.171429                  0.015611                 9.0     0.029537   \n",
       "4         0.200000                  0.002449                10.0     0.013344   \n",
       "\n",
       "   dim_5__std  \n",
       "0    0.510274  \n",
       "1    0.661172  \n",
       "2    0.499788  \n",
       "3    0.248161  \n",
       "4    0.163754  \n",
       "\n",
       "[5 rows x 144 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c24_mv.transform(BM_X_train).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. catch22 Forest Classifier\n",
    "\n",
    "For classification tasks the default classifier to use with the catch22 features is random forest classifier.\n",
    "An implementation making use of the `RandomForestClassifier` from sklearn built on catch22 features is provided in the form on the `Catch22Classifier` for ease of use."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.431962Z",
     "iopub.status.busy": "2020-12-19T14:30:08.419431Z",
     "iopub.status.idle": "2020-12-19T14:30:08.535295Z",
     "shell.execute_reply": "2020-12-19T14:30:08.535836Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 {color: black;background-color: white;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 pre{padding: 0;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-toggleable {background-color: white;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-estimator:hover {background-color: #d4ebff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-item {z-index: 1;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel-item {display: flex;flex-direction: column;position: relative;background-color: white;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-parallel-item:only-child::after {width: 0;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;position: relative;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-label label {font-family: monospace;font-weight: bold;background-color: white;display: inline-block;line-height: 1.2em;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-label-container {position: relative;z-index: 2;text-align: center;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-6102bcc1-e92f-4367-9239-29e5a44e6264 div.sk-text-repr-fallback {display: none;}</style><div id='sk-6102bcc1-e92f-4367-9239-29e5a44e6264' class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Catch22Classifier(random_state=0)</pre><b>Please rerun this cell to show the HTML repr or trust the notebook.</b></div><div class=\"sk-container\" hidden><div class='sk-item'><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=UUID('3ed534ad-4b0b-4186-81a8-57e37d4481dc') type=\"checkbox\" checked><label for=UUID('3ed534ad-4b0b-4186-81a8-57e37d4481dc') class='sk-toggleable__label sk-toggleable__label-arrow'>Catch22Classifier</label><div class=\"sk-toggleable__content\"><pre>Catch22Classifier(random_state=0)</pre></div></div></div></div></div>"
      ],
      "text/plain": [
       "Catch22Classifier(random_state=0)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c22f = Catch22Classifier(random_state=0)\n",
    "c22f.fit(IPD_X_train, IPD_y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-12-19T14:30:08.553299Z",
     "iopub.status.busy": "2020-12-19T14:30:08.552508Z",
     "iopub.status.idle": "2020-12-19T14:30:08.561331Z",
     "shell.execute_reply": "2020-12-19T14:30:08.561821Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C22F Accuracy: 0.86\n"
     ]
    }
   ],
   "source": [
    "c22f_preds = c22f.predict(IPD_X_test)\n",
    "print(\"C22F Accuracy: \" + str(metrics.accuracy_score(IPD_y_test, c22f_preds)))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
